from django.shortcuts import render
from django.http import HttpResponse, StreamingHttpResponse
import csv


def index(request):
    res = HttpResponse(content_type='text/csv')
    res['Content-Disposition'] = 'attachment; filename=abc.csv'
    writer = csv.writer(res)
    writer.writerow(['username', 'age'])
    return res


def large_csv(request):
    res = StreamingHttpResponse(content_type='text/csv')
    res['Content-Disposition'] = 'attachment; filename=large.csv'
    res.streaming_content = ("username, age")
    return res
